package com.untour.seqid.config.leaf;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Data
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = "leaf")
public class LeafProperties {

    private Segment segment;

    @Data
    public static class Segment {

        /**
         * 最大步长不超过100,0000
         */
        private int maxStep = 1000000;

        /**
         * 一个Segment维持时间为15分钟
         */
        private long segmentDuration = 15 * 60 * 1000L;

        //定时更新数据库数据-初始化延迟时间
        private long initialDelay = 60;

        //定时更新数据库数据-延迟时间
        private long delay = 60;

        //定时更新数据库数据-延迟时间单位
        private TimeUnit timeUnit = TimeUnit.SECONDS;
        //睡眠毫秒
        private int sleepMillis = 10;
        //睡眠次数
        private int cycles = 100;
    }

}
